import syscall

string s = 'hello world!'
var raw_str = s.ref()
int result = syscall.call6(syscall.SYS_WRITE, syscall.STDOUT_FILENO as cptr, raw_str, s.len as cptr, 0, 0, 0)

// read
var fd = syscall.open('./mock/stat.txt', syscall.O_RDONLY, 0666)

var buf = vec<u8>{len=100} // 预先申请好了空间, 便于 syscall 中将相应的值回写
print('buf len: ', buf.len, ', buf cap: ', buf.cap, '\n')

result = syscall.call6(syscall.SYS_READ, fd as cptr, buf.ref(), buf.len as cptr, 0, 0, 0)

print('read result: ', result, '\n')
buf = buf.slice(0, result)
print('buf: ', buf as string, '!!!', '\n')


// clock_gettime
var t = syscall.clock_gettime(syscall.CLOCK_REALTIME)
println('sec:', t.sec > 1691651852, 'nsec:', t.nsec > 0)

// env
syscall.set_env('NICE', 'hello man')
var env = syscall.get_env('NICE')
println('env:', env)